package cn.itcast.util;

import java.util.Calendar;

public class DateTimeUtil {
    /**|
     * 1.新建Calendar对象，设置日期
     * 2.设置开市时间
     * 3.设置闭市时间
     */
    public static long openTime = 0L;
    public static long closeTime = 0L;

    static {
        //1.新建Calendar（日历）对象，设置日期
        Calendar calendar = Calendar.getInstance();
        //2.设置开市时间
        calendar.set(Calendar.HOUR_OF_DAY,9);//24小时制的9点
        calendar.set(Calendar.MINUTE,30); //9:30:00
        calendar.set(Calendar.SECOND,0);
        //获取开始时间
        openTime = calendar.getTime().getTime();
        //3.设置闭市时间
        calendar.set(Calendar.HOUR_OF_DAY,23);
        calendar.set(Calendar.MINUTE,59);  //23:00:00
        calendar.set(Calendar.SECOND,0);

        //获取关闭市时间
        closeTime = calendar.getTime().getTime();
    }

    public static void main(String[] args) {
        System.out.println(openTime);
        System.out.println(closeTime);
    }

}
